package com.aaa.controller;

import com.aaa.entity.Apply;
import com.aaa.service.impl.ApplyServiceimpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("apply")
public class Applycontroller {
    @Resource
    ApplyServiceimpl applyserviceimpl;

    @ResponseBody
    @RequestMapping("findpage")
    public Map<String, Object> userList(Integer pageSize, Integer pageNum) {
        Map<String, Object> map = new HashMap<>();
        List<Apply> userList = applyserviceimpl.findpage(pageSize, pageNum * pageSize);
        Integer TotalNum = applyserviceimpl.findcount();

        map.put("userList", userList);
        map.put("TotalNum", TotalNum);
        return map;
    }
    @ResponseBody
    @RequestMapping("add")
    public Integer add(Apply apply){
        apply.setTime(new Date());
        return applyserviceimpl.add(apply);
    }

}
